package it.stepava.f1countdown;

import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.widget.RemoteViews;

public class f1countdown extends AppWidgetProvider
{
	public Integer intTime = 1;

	public void onUpdate( Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds )
	{
		RemoteViews widgetView;
		final int N = appWidgetIds.length;

		// Perform this loop procedure for each App Widget that belongs to this provider
		for (int i=0; i<N; i++) {
			int appWidgetId = appWidgetIds[i];

			//ComponentName F1CountdownWidget;
			widgetView = new RemoteViews(context.getPackageName(), R.layout.main );
			//F1CountdownWidget = new ComponentName(context, f1countdown.class );
			intTime = intTime + 1;
			String time = Integer.toString(intTime);
			widgetView.setTextViewText(R.id.date, "Formula 1");
			widgetView.setTextViewText(R.id.time, time);
			Intent BrowserIntent = new Intent("android.intent.action.VIEW", Uri.parse("http://www.formula1.com"));
			PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, BrowserIntent, 0);
			widgetView.setOnClickPendingIntent(R.id.date, pendingIntent);
			appWidgetManager.updateAppWidget(appWidgetId, widgetView);
		}
	}
}